// 遍历移除法
let nums = [1,1,2]

for(let i = 0; i < nums.length; i++){
  if(nums[i]===nums[i+1]){
    nums.splice(i,1);
    i--
  }
}
console.log(nums.length)

// 双指针法
let nums = [2,2,3,3,3,4]
for (var fater = 0 ,child = 0; fater < nums.length; fater++) {
  if(nums[child] !== nums[fater]){
    child ++
    nums[child] = nums[fater]
  }
}
console.log(child + 1)